package com.siashan.toolkit.captcha.google;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import lombok.Getter;
import lombok.Setter;

/**
 * Google图形验证码构造器
 *
 * @author siashan
 * @since v1.0.3
 **/
@Setter
@Getter
public class GoogleCaptchaBuilder {


    /**
     * 构造GoogleCaptcha
     */
    public static GoogleCaptcha build() {
        DefaultKaptcha defaultKaptcha = CaptchaConfig.defaultKaptcha;
        return new GoogleCaptcha(defaultKaptcha);
    }

    /**
     * 构造GoogleCaptcha
     * @param captchaType 验证码类型
     */
    public static GoogleCaptcha build(GoogleCaptchaType captchaType) {
        DefaultKaptcha defaultKaptcha = null;
        switch (captchaType){
            case IMG:
                defaultKaptcha = CaptchaConfig.defaultKaptcha;
                break;
            case MATH:
                defaultKaptcha = CaptchaConfig.mathKaptcha;
                break;
            case CHINESE:
                defaultKaptcha = CaptchaConfig.chineseKaptcha;
                break;
            default:
                defaultKaptcha = CaptchaConfig.defaultKaptcha;
                break;

        }
        return new GoogleCaptcha(defaultKaptcha,captchaType);
    }
}
